<template>
  <el-card shadow="never">
    <e-table
      ref="eTable"
      @getList="handleGetList"
      :tableData="tableData"
      :columns="columns"
      :loading="loading"
      :total="total"
    />
  </el-card>
</template>

<script>
import { getInnerDeptInfoMonitor } from '@/api/reports'
export default {
  data() {
    return {
      total: 1,
      loading: false,
      tableData: [],
      columns: [],
      queryParam: {
        pageSize: 10,
        pageNo: 1
      }
    }
  },
  methods: {
    //columns 动态删减，根据form传递过来的数据
    async handleGetList(param = {}) {
      this.loading = true
      this.columns = [
        {
          label: '住院总收入',
          prop: 'inner_inc'
        },
        {
          label: '出院人次',
          prop: 'out_num'
        },
        {
          label: '住院医疗收入',
          prop: 'inner_medical_inc'
        },
        {
          label: '住院药品收入',
          prop: 'inner_drug_inc'
        },
        {
          label: '住院床位收入',
          prop: 'inner_bed_inc'
        },
        {
          label: '住院检查收入',
          prop: 'inner_chk_inc'
        },
        {
          label: '住院药品收入',
          prop: 'inner_treat_inc'
        },
        {
          label: '住院手术收入',
          prop: 'inner_oper_inc'
        },
        {
          label: '床位使用率',
          prop: 'bed_use_rate'
        },
        {
          label: '床位周转次数',
          prop: 'bed_turnover_num'
        },
        {
          label: '每住院人次费用',
          prop: 'inner_avg_fee'
        },
        {
          label: '平均住院日',
          prop: 'inner_avg_day'
        }
      ]
      this.queryParam = Object.assign(this.queryParam, param)

      if (this.queryParam.deptState) {
        this.columns.unshift({
          label: '科室名称',
          prop: 'his_dept_name'
        })
      }
      if (this.queryParam.dateState) {
        this.columns.unshift({
          label: '日期',
          prop: 'dt'
        })
      }
      const res = await getInnerDeptInfoMonitor(this.queryParam)
      if (res && res.data.records.length > 0) {
        const {
          state,
          data: { records, total }
        } = res
        this.tableData = records
        this.total = total
      } else {
        this.tableData = []
        this.total = 1
      }
      this.loading = false
    }
  }
}
</script>
